<%@page import="com.jfinal.kit.PropKit" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" import="cn.com.dashihui.web.common.OrderCode" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<!DOCTYPE html>
<html>
<head>
    <title>订单管理</title>
    <jsp:include page="../../include/header.jsp"></jsp:include>
    <style type="text/css">
			table th{
						text-align: center;
			            white-space: nowrap;
			        }
			table td{
						text-align: center;
			            white-space: nowrap;
			        }
			  table{
			         empty-cells:show; 
			         border-collapse: collapse;
			         margin:0 auto;
			        }
					 	  /*排序 */
			.querySort{
			   position:relative;
			}
			.down{
			   position: absolute;
			   top:12px;
			   display:inline-block;
			   width:10px;
			   height:12px;
			   margin-left: 8px;
			   background: url("${BASE_PATH}/static/images/sprite-arrow.png") 0 61px;
			}
		  .sort .querySort:NTH-OF-TYPE(2) .down{
			    top:-3px;
			    transform: rotateX(180deg);
			}
			.querySort:hover .down{
			   background: url("${BASE_PATH}/static/images/sprite-arrow.png") 0 21px;
			}
			
		  .downSort{
			    position: absolute;
			    top: 3px;
			    left: 3px;
			    width: 18px;
			    height: 24px;
			    opacity: 0;
			    cursor:pointer;
			}
		    .upSort {
			    position: absolute;
			    top: -15px;
			    left: 3px;
			    width: 18px;
			    height: 24px;
			    opacity: 0; 
			    cursor:pointer;
			}

            
		</style>
	</head>
<body>
<div id="wrapper"  class="row">
	
			<div class="col-lg-12">
				<h1 class="page-header">订单统计</h1>
			</div>
	<!-- 表格 -->
	<div class="table-responsive panel panel-default" >
			<table id="dataTable" class="table table-hover table-bordered" style="overflow:scroll;">
	            <thead>
	               	<tr>
						<th width="200px;">订单号</th>
						<th width="150px;">商品名称</th>
						<th width="120px;">联系方式</th>
						<th width="200px;">下单时间</th>
						<th width="80px;">订单总价值</th>
						<th width="200px;">支付时间</th>
						<th width="100px;">状态</th>
					</tr>
	            </thead>
	            <tbody id="dataList"></tbody>
			</table>
		</div>
			<div class="col-lg-12">
        		<div class = "pull-right">
        			<div class="text-muted  pull-left" style="margin-top:20px; margin-right:18px;">
					<select id="pageSize" name="pageSize" class="selectpicker" data-width="100" onchange="query()" >
    					<option value="10" selected = "selected">10条/页</option>
						<option value="15">15条/页</option>
						<option value="20">20条/页</option>
						<option value="50">50条/页</option>
						<option value="100">100条/页</option>
    				</select>
					</div>
        			<ul id="dataPagination" class="pagination-sm pull-right"></ul>
        		</div>
			</div>
	</div>
	<jsp:include page="../../include/javascripts.jsp"></jsp:include>
<!-- 异步加载下一页数据后，用模板渲染 -->
<script type="text/html" id="dataTpl">
		{{each list as item}}
				 <tr id="item{{item.orderNum}}" data-id="{{item.orderNum}}">
					<td>{{item.orderNum}}</td>
                    <td>{{item.goodsName}}</td>
					<td>{{item.tel}}</td>
					<td>{{item.startDate}}</td>
					<td>{{item.amount}}</td>
					<td>{{item.payDate}}
						{{if !item.payDate}}尚未支付或已删除{{/if}}
					</td>
					{{if item.orderState == 1}}
						<td>待付款</td>
					{{else if item.orderState == 2}}
						<td>
							<font color="#EE2C2C" id="dataCount">待出库</font>
						</td>
					{{else if item.orderState == 3}}
						<td>待评价</td>
					{{else if item.orderState == 4}}
						<td>已完成</td>
					{{else if item.orderState == 5}}
						<td>删除</td>	
					{{else if item.orderState == 6}}
						<td>待收货</td>	
					{{/if}}
				</tr>
		{{/each}}
</script>
<script type="text/javascript">
var dataPaginator;
var OrderNum="${OrderNum}";
var userid="${userid}";
$(query);
function query(){
	var pageSize=$("#pageSize").val();
	var params = {
		pageSize:pageSize,
		userid:userid
	};
	if(dataPaginator){
		dataPaginator.destroy();
	}
	if(!userid){
		dataPaginator = Kit.pagination("#dataPagination","${BASE_PATH}/bus/order/ordergb",params,function(result){
			//设置显示最新的数据数量
			$("#dataCount").html(result.object.totalRow);
			//根据模板渲染数据并填充
			$("#dataList").empty().append(template("dataTpl",result.object));
		});
		
	}else{
		//根据用户Id查询此用户所有订单
		dataPaginator = Kit.pagination("#dataPagination","${BASE_PATH}/bus/order/ordergb",{userid:userid,pageSize:pageSize},function(result){
			//设置显示最新的数据数量
			$("#dataCount").html(result.object.totalRow);
			//根据模板渲染数据并填充
			$("#dataList").empty().append(template("dataTpl",result.object));
		});
	}
}
//显示订单详细信息

var showOrderDialog;
function showOrder(orderNum){
	showOrderDialog = Kit.dialog("查看订单","${BASE_PATH}/bus/order/detail?orderNum="+orderNum,{size:'size-wide',closable:true}).open();
}
//显示会员详细信息
function showUser(id){
	if(id){
		showDialog = Kit.dialog("会员详情信息","${BASE_PATH}/bus/order/userdetail/"+id,{size:'size-wide',closable:true}).open();
	}else{
		//根据用户Id查询此用户所有订单
		showDialog = Kit.dialog("会员详情信息","${BASE_PATH}/bus/order/userdetail/"+userId,{size:'size-wide',closable:true}).open();
	}
}
</script>
</body>
</html>